package com.rabbit.eap.framework.core.pagination;

import com.rabbit.eap.common.constant.PageConstant;
import com.rabbit.eap.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @projectName eap
 * @packageName com.rabbit.eap.framework.core.pagination
 * @className BasePageParam
 * @author： rabbit
 * @version： 1.0
 * @since： 2020/4/8 01:05
 * <p>Description: 查询参数 </p>

 */
@Data
@ApiModel("查询参数对象")
public class BasePageParam extends BaseEntity {
    @ApiModelProperty(value = "页码,默认为1", example = "1")
    private Long pageIndex = PageConstant.DEFAULT_PAGE_INDEX;

    @ApiModelProperty(value = "页大小,默认为10", example = "10")
    private Long pageSize = PageConstant.DEFAULT_PAGE_SIZE;

    @ApiModelProperty(value = "搜索字符串", example = "")
    private String keyword;

    public void setPageIndex(Long pageIndex) {
        if (pageIndex == null || pageIndex <= 0) {
            this.pageIndex = PageConstant.DEFAULT_PAGE_INDEX;
        } else {
            this.pageIndex = pageIndex;
        }
    }

    public void setPageSize(Long pageSize) {
        if (pageSize == null || pageSize <= 0) {
            this.pageSize = PageConstant.DEFAULT_PAGE_SIZE;
        } else {
            this.pageSize = pageSize;
        }
    }
}
